/**
 * 
 */
package com.fox.webapp.web;

import java.io.UnsupportedEncodingException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.thymeleaf.expression.Strings;

import com.fox.webapp.domain.Article;
import com.fox.webapp.service.IArticleService;

/**
 * @author yockii
 *
 */
@Controller
@RequestMapping("c")
public class ArticleController {

	private static final Logger logger = LoggerFactory.getLogger(ArticleController.class);
	@Autowired
	private IArticleService articleService;
	
	@RequestMapping(value = "a/{englishName}", method = RequestMethod.GET)
	public String getArticleFromTitle(Model model, @PathVariable String englishName){
		Article a = articleService.getArticleByEnglishName(englishName);
		model.addAttribute("article", a);
		return "article/article";
	}
	
	@RequestMapping(value = "i/{articleId}", method = RequestMethod.GET)
	public String getArticle(Model model, @PathVariable String articleId){
		Article a = articleService.getArticle(articleId);
		model.addAttribute("article", a);
		return "article/article";
	}
}
